home *** CD-ROM | disk | FTP | other *** search
- '------------------------------------------------------------------------------
- '------------------------------------------------------------------------------
- '--
- '-- Visio OLE Automation
- '-- Shape Sheet "Wrappers"
- '--
- '-- File Name : vissheet.bas
- '--
- '-- Description : Contains high level interface to the four changeable shape
- '-- sheet sections (Geometry, Scratch, Control Point and
- '-- Connection Point).
- '--
- '------------------------------------------------------------------------------
- '------------------------------------------------------------------------------
- 'This file contains sample code for using Visual Basic and OLE 2.0 to
- 'automatically create a Visio network diagram from a Microsoft Access
- 'database.
- '
- 'IMPORTANT: NETVB.ZIP is ONLY a sample, not a released product. It was
- 'not extensively tested, and has no guarantee. In addition, we do not provide
- 'documentation or support for this file.
-
- Option Explicit
-
- '--
- '-- Type & Global Declarations
- '--
-
- Global Const SIDE_TOP = 1
- Global Const SIDE_BOTTOM = 2
- Global Const SIDE_LEFT = 3
- Global Const SIDE_RIGHT = 4
-
- Global Const visLineTo = 0
- Global Const visArcTo = 1
- Global Const visElArctTo = 2
-
- Type VisPoint
- X As Variant
- Y As Variant
- End Type
-
- Type CtrlHandle
- X As Variant
- Y As Variant
- XDynamic As Variant
- YDynamic As Variant
- XBehavior As Variant
- YBehavior As Variant
- CanGlue As Variant
- End Type
-
- Type ScratchRow
- X As Variant
- Y As Variant
- A As Variant
- B As Variant
- C As Variant
- D As Variant
- End Type
-
- Type CnctPoint
- X As Variant
- Y As Variant
- End Type
-
- Type Vertex
- VtxType As Integer
-
- X As Variant
- Y As Variant
-
- Bow As Variant
-
- XControlPoint As Variant
- YControlPoint As Variant
- Ecentricity As Variant
- MajMinRatio As Variant
- End Type
-
- Function AddCnctPoint (shp As Object, iPos As Integer) As Integer
- '-----------------------------------
- '--- AddCnctPoint ------------------
- '--
- '-- Use AddCnctPoint to add a new control point to a Shape object.
- '--
- '-- Parameters : shp - Visio Shape object to add row to.
- '-- iPos - 1 based index of new point (row) to be added. Also
- '-- accepts visRowLLast.
- '--
- '-- Return Value : 1 based index of point added if no error occurs. Otherwise
- '-- visRowNone.
- '--
-
- Dim iRowIndex As Integer, iTemp As Integer
-
- If Not IsShape(shp) Or Not (iPos > 0 Or iPos = visRowLast) Then
- AddCnctPoint = visRowNone
- Exit Function
- End If
-
- If iPos <> visRowLast Then '-- Index Was Passed...
- iRowIndex = visRowFirst + (iPos - 1) '-- Convert To Row Index
- Else '-- Otherwise...
- iRowIndex = visRowLast '-- Use Last Row
- End If
-
- '-- Next we add the row. If all goes well iTemp should be the 0 based row
- '-- index added. If visRowNone is not returned we add one to it to make the
- '-- 1 based index.
-
- iTemp = shp.AddRow(visSectionExport, iRowIndex, 0)
-
- If iTemp <> visRowNone Then iTemp = iTemp + 1
-
- AddCnctPoint = iTemp
- End Function
-
- Function AddCtrlHandle (shp As Object, iPos As Integer) As Integer
- '-----------------------------------
- '--- AddCtrlHandle -----------------
- '--
- '-- Use AddCtrlHandle to add a new control handle to a Shape object.
- '--
- '-- Parameters : shp - Visio Shape object to add handle to.
- '-- iPos - 1 based index of handle (row) to be added. Also
- '-- accepts visRowLLast.
- '--
- '-- Return Value : 1 based index of handle added if no error occurs. Otherwise
- '-- visRowNone.
- '--
-
- Dim iRowIndex As Integer, iTemp As Integer
-
- If Not IsShape(shp) Or Not (iPos > 0 Or iPos = visRowLast) Then
- AddCtrlHandle = visRowNone
- Exit Function
- End If
-
- If iPos <> visRowLast Then '-- Index Was Passed...
- iRowIndex = visRowFirst + (iPos - 1) '-- Convert To Row Index
- Else '-- Otherwise...
- iRowIndex = visRowLast '-- Use Last Row
- End If
-
- '-- Next we add the row. If all goes well iTemp should be the 0 based row
- '-- index added. If visRowNone is not returned we just add one to the row
- '-- index and return it.
-
- iTemp = shp.AddRow(visSectionControls, iRowIndex, 0)
-
- If iTemp <> visRowNone Then iTemp = iTemp + 1
-
- AddCtrlHandle = iTemp
- End Function
-
- Function AddGmtrySect (shp As Object, iSection As Integer) As Integer
- '-----------------------------------
- '--- AddGmtrySect ------------------
- '--
- '-- Adds a geometry section to a shape sheet using 1 based indexes. If the
- '-- section index passed is larger than the section count the new section is
- '-- added at the end.
- '--
- '-- Parameters : shp - Visio Shape to add section to.
- '-- iSection - 1 based index of section to add. If the section
- '-- exists a blank one is inserted. visSecLLast is
- '-- a valid argument.
- '--
- '-- Return Value : visSecNone if an error occurs, otherwise the 1 based index
- '-- of the section added.
- '--
-
- Dim iSecIndex As Integer, iTemp As Integer
-
- AddGmtrySect = visSectionNone '-- Default To No Section Added
-
- If Not IsShape(shp) Or Not (iSection > 0 Or iSection = visSectionLastComponent) Then
- Exit Function
- End If
-
- If iSection <> visSectionLastComponent Then
- iSecIndex = visSectionFirstComponent + (iSection - 1)
- Else
- iSecIndex = visSectionLastComponent
- End If
- '--
- '-- Now we add the row. On return, iTemp either has visSecNone if an error
- '-- occurred or the index of the section added. If visSecNone we just exit
- '-- out. Otherwise we use iTemp to add the property and Move To rows at the
- '-- beginning of the section. Finally we return the 1 based sectio index.
- '--
-
- iTemp = shp.AddSection(iSecIndex)
-
- If iTemp <> visSectionNone Then
- shp.AddRow iTemp, visRowFirst, visTagComponent
- shp.AddRow iTemp, visRowFirst + 1, visTagMoveTo
-
- AddGmtrySect = iTemp + 1 - visSectionFirstComponent
- End If
- End Function
-
- Function AddScratchRow (shp As Object, iPos As Integer) As Integer
- '-----------------------------------
- '--- AddScratchRow -----------------
- '--
- '-- Adds a new scratch row to a Shape object.
- '--
- '-- Parameters : shp - Visio Shape object to add row to.
- '-- iPos - 1 based index of new row to be added. Accepts
- '-- visRowLLast.
- '--
- '-- Return Value : 1 based index of row added if no error occurs. Otherwise
- '-- visRowNone.
- '--
-
- Dim iRowIndex As Integer, iTemp As Integer
-
- If Not IsShape(shp) Or Not (iPos > 0 Or iPos = visRowLast) Then
- AddScratchRow = visRowNone
- Exit Function
- End If
-
- If iPos <> visRowLast Then '-- Index Was Passed...
- iRowIndex = visRowFirst + (iPos - 1) '-- Convert To Row Index
- Else '-- Otherwise...
- iRowIndex = visRowLast '-- Use Last Row
- End If
-
- '-- Next we add the row. If all goes well iTemp should be the 0 based row
- '-- index added. If it doesn't match with iRowIndex then an error occured
- '-- and we return the proper error code.
-
- iTemp = shp.AddRow(visSectionScratch, iRowIndex, 0)
-
- If iTemp <> visRowNone Then iTemp = iTemp + 1
-
- AddScratchRow = iTemp
- End Function
-
- Function BestExportPoint (shp As Object, iSide As Integer) As Integer
- '-----------------------------------
- '--- BestExportPoint ---------------
- '--
- '-- Finds the best connection(export) point on a shape for any given side.
- '--
- '-- Return Value : 1 based index of best export point.
- '--
-
- Dim dMax As Double, dResult As Double, cell As Object
- Dim iBest As Integer, iRow As Integer, iCol As Integer
- Dim iRows As Integer
-
- If Not IsShape(shp) Then Exit Function
-
- iBest = 1
- dMax = 0
- iRows = shp.RowCount(visSectionExport)
-
- Select Case iSide
- Case SIDE_LEFT, SIDE_RIGHT: iCol = 0
- Case SIDE_TOP, SIDE_BOTTOM: iCol = 1
- End Select
-
- For iRow = 0 To iRows
- Set cell = shp.CellsSRC(visSectionExport, iRow, iCol)
- dResult = cell.ResultIU
-
- Select Case iSide
- Case SIDE_LEFT, SIDE_BOTTOM
- If dResult < dMax Then
- dMax = dResult
- iBest = iRow
- End If
- Case SIDE_RIGHT, SIDE_TOP
- If dResult > dMax Then
- dMax = dResult
- iBest = iRow
- End If
- End Select
- Next iRow
-
- BestExportPoint = (iBest + 1)
- End Function
-
- Sub DelConnectSection (shp As Object)
- '-----------------------------------
- '--- DelConnectSection -------------
- '--
- '-- Removes the Connection section from a shape sheet. Use carefully!
- '--
- '-- Paremeters : shp - Shape sheet to remove connection section from.
- '--
-
- If IsShape(shp) Then shp.DeleteSection visSectionExport
- End Sub
-
- Sub DeleteCnctPoint (shp As Object, iPos As Integer)
- '-----------------------------------
- '--- DeleteCnctPoint ---------------
- '--
- '-- Use DeleteCnctPoint to remove a connection point from a Shape object.
- '-- Offers 1 based row indexes and a safe method for deleting points. Will not
- '-- remove the connection section if deleting the last row. If the row index
- '-- passed does not exist then nothing is deleted.
- '--
- '-- Parameters : shp - Shape to delete point from.
- '-- iPos - 1 based index of point to be deleted. Do NOT use
- '-- row constants.
- '--
-
- If Not IsShape(shp) Or (iPos <= 0) Then Exit Sub
-
- shp.DeleteRow visSectionExport, visRowFirst + (iPos - 1)
- End Sub
-
- Sub DeleteCtrlHandle (shp As Object, iPos As Integer)
- '-----------------------------------
- '--- DeleteCtrlHandle --------------
- '--
- '-- Use DeleteCtrlHandle to remove a control handle from a Shape object.
- '-- Offers 1 based row indexes and a safe method for deleting handles. Will not
- '-- remove the controls section if deleting the last row. If the row index
- '-- passed does not exist then nothing is deleted.
- '--
- '-- Parameters : shp - Shape to delete handle from.
- '-- iPos - 1 based index of handle to be deleted. Do NOT use
- '-- row constants.
- '--
-
- If Not IsShape(shp) Or (iPos <= 0) Then Exit Sub
-
- shp.DeleteRow visSectionControls, visRowFirst + (iPos - 1)
- End Sub
-
- Sub DeleteScratchRow (shp As Object, iPos As Integer)
- '-----------------------------------
- '--- DeleteScratchRow --------------
- '--
- '-- Use DeleteScratchRow to remove a scratch row from a Shape object.
- '-- Offers 1 based row indexes and a safe method of deleting rows. Will not
- '-- remove the scratch section if deleting the last row. If the row index
- '-- passed does not exist then nothing is deleted.
- '--
- '-- Parameters : shp - Shape to delete row from.
- '-- iPos - 1 based index of row to be deleted. Do NOT use
- '-- row constants.
- '--
- '-- Return Value : None
- '--
-
- If Not IsShape(shp) Or (iPos <= 0) Then Exit Sub
-
- shp.DeleteRow visSectionScratch, visRowFirst + (iPos - 1)
- End Sub
-
- Sub DelGmtrySect (shp As Object, iSection As Integer)
- '-----------------------------------
- '--- DelGmtrySect ------------------
- '--
- '-- Deletes a geometry section from a shape sheet.
- '--
- '-- Parameters : shp - Shape object from which to delete the section.
- '-- iSection - 1 based index of section to delete. If the section
- '-- does not exists nothing is deleted. visSecLLast
- '-- is a valid argument.
- '--
-
- Dim iSecIndex As Integer
-
- If Not IsShape(shp) Or Not (iSection > 0 Or iSection = visSectionLastComponent) Then
- Exit Sub
- End If
-
- If iSecIndex <> visSectionLastComponent Then
- iSecIndex = visSectionFirstComponent + (iSection - 1)
- Else
- iSecIndex = visSectionLastComponent
- End If
-
- shp.DeleteSection iSecIndex
- End Sub
-
- Sub DelHandleSection (shp As Object)
- '-----------------------------------
- '--- DelHandleSection --------------
- '--
- '-- Removes the Control handles section from a shape sheet. Use carefully!
- '--
- '-- Paremeters : shp - Shape sheet to remove control handle section from.
- '--
-
- If IsShape(shp) Then shp.DeleteSection visSectionControls
- End Sub
-
- Sub DelScratchSection (shp As Object)
- '-----------------------------------
- '--- DelScratchSection -------------
- '--
- '-- Removes the Scratch section from a shape sheet. Use carefully!
- '--
- '-- Paremeters : shp - Shape sheet to remove Scratch section from.
- '--
-
- If IsShape(shp) Then shp.DeleteSection visSectionScratch
- End Sub
-
- Function GetClosedFlag (shp As Object, iSection As Integer) As Variant
- '-----------------------------------
- '--- GetClosedFlag -----------------
- '--
- '-- Returns the Closed flag formula for a geometry section.
- '--
- '-- Parameters : shp - Shape sheet to act upon.
- '-- iSection - 1 based index of section to get Closed flag from.
- '--
- '-- Return Value : Variant containing the Closed flag formula. Null if the
- '-- section doesn't exist.
- '--
-
- If Not (iSection >= 1 And iSection <= GmtryCount(shp)) Then
- GetClosedFlag = Null
- Exit Function
- End If
-
- GetClosedFlag = shp.CellsSRC(visSectionFirstComponent + (iSection - 1), 0, 0).Formula
- End Function
-
- Sub GetCnctPoint (shp As Object, iPos As Integer, Pnt As CnctPoint)
- '-----------------------------------
- '--- GetCnctPoint ------------------
- '--
- '-- Retrieves a connection point structure from a shape.
- '--
- '-- Parameters : shp - Shape sheet to get point from.
- '-- iPos - 1 based index of point to retrieve. Do NOT use
- '-- row constants.
- '-- Pnt - Structure to receive connect point's contents.
- '--
-
- Dim iRowIndex As Integer
-
- 'If Not IsShape(shp) Then Exit Sub 'Called By TotalCnctPts!
- If Not (iPos >= 1 And iPos <= TotalCnctPts(shp)) Then Exit Sub
-
- iRowIndex = visRowFirst + (iPos - 1) '-- Convert Index
-
- Pnt.X = shp.CellsSRC(visSectionExport, iRowIndex, 0).Formula
- Pnt.Y = shp.CellsSRC(visSectionExport, iRowIndex, 1).Formula
- End Sub
-
- Sub GetCtrlHandle (shp As Object, iPos As Integer, Pnt As CtrlHandle)
- '-----------------------------------
- '--- GetCtrlHandle -----------------
- '--
- '-- Retrieves a control handle structure from a shape.
- '--
- '-- Parameters : shp - Shape sheet to get handle from.
- '-- iPos - 1 based index of handle to retrieve. Do NOT use
- '-- row constants.
- '-- Pnt - Structure to receive control handle's contents.
- '--
-
- Dim iRowIndex As Integer
-
- 'If Not IsShape(shp) Then Exit Sub 'Called By TotalCtrlPts!
- If Not (iPos >= 1 And iPos <= HandleCount(shp)) Then Exit Sub
-
- iRowIndex = visRowFirst + (iPos - 1) '-- Convert Index
-
- Pnt.X = shp.CellsSRC(visSectionControls, iRowIndex, 0).Formula
- Pnt.Y = shp.CellsSRC(visSectionControls, iRowIndex, 1).Formula
- Pnt.XDynamic = shp.CellsSRC(visSectionControls, iRowIndex, 2).Formula
- Pnt.YDynamic = shp.CellsSRC(visSectionControls, iRowIndex, 3).Formula
- Pnt.XBehavior = shp.CellsSRC(visSectionControls, iRowIndex, 4).Formula
- Pnt.YBehavior = shp.CellsSRC(visSectionControls, iRowIndex, 5).Formula
- Pnt.CanGlue = shp.CellsSRC(visSectionControls, iRowIndex, 6).Formula
- End Sub
-
- Sub GetCtrlHandlePt (shp As Object, iPos As Integer, Pnt As VisPoint)
- '-----------------------------------
- '--- GetCtrlHandle -----------------
- '--
- '-- Retrieves a control handle X,Y point structure from a shape.
- '--
- '-- Parameters : shp - Shape sheet to get handle from.
- '-- iPos - 1 based index of handle to retrieve. Do NOT use
- '-- row constants.
- '-- Pnt - Structure to receive control handle's X,Y point.
- '--
-
- Dim iRowIndex As Integer
-
- 'If Not IsShape(shp) Then Exit Sub 'Called By TotalCtrlPts!
- If Not (iPos >= 1 And iPos <= HandleCount(shp)) Then Exit Sub
-
- iRowIndex = visRowFirst + (iPos - 1) '-- Convert Index
-
- Pnt.X = shp.CellsSRC(visSectionControls, iRowIndex, 0).Formula
- Pnt.Y = shp.CellsSRC(visSectionControls, iRowIndex, 1).Formula
- End Sub
-
- Function GetHiddenFlag (shp As Object, iSection As Integer) As Variant
- '-----------------------------------
- '--- GetHiddenFlag -----------------
- '--
- '-- Returns the Hidden flag formula for a given geometry section.
- '--
- '-- Parameters : shp - Shape sheet to act upon.
- '-- iSection - 1 based index of section to get Hidden flag from.
- '--
- '-- Return Value : Variant containing the Hidden flag formula. Null if the
- '-- section doesn't exist.
- '--
-
- If Not (iSection >= 1 And iSection <= GmtryCount(shp)) Then
- GetHiddenFlag = Null
- Exit Function
- End If
-
- GetHiddenFlag = shp.CellsSRC(visSectionFirstComponent + (iSection - 1), 0, 2).Formula
- End Function
-
- Sub GetScratchRow (shp As Object, iPos As Integer, Row As ScratchRow)
- '-----------------------------------
- '--- GetScratchRow -----------------
- '--
- '-- Retrieves a scratch row from a shape sheet. If the row does not exist
- '-- then nothing is retrieved.
- '--
- '-- Parameters : shp - Shape sheet to get row from.
- '-- iPos - 1 based index of row to retrieve. Do NOT use
- '-- row constants.
- '-- Row - Structure to receive the row's content.
- '--
-
- Dim iRowIndex As Integer
-
- 'If Not IsShape(shp) Then Exit Sub 'Called By TotalScratchRows!
- If Not (iPos >= 1 And iPos <= TotalScratchRows(shp)) Then Exit Sub
-
- iRowIndex = visRowFirst + (iPos - 1)
-
- Row.X = shp.CellsSRC(visSectionScratch, iRowIndex, 0).Formula
- Row.Y = shp.CellsSRC(visSectionScratch, iRowIndex, 1).Formula
- Row.A = shp.CellsSRC(visSectionScratch, iRowIndex, 2).Formula
- Row.B = shp.CellsSRC(visSectionScratch, iRowIndex, 3).Formula
- Row.C = shp.CellsSRC(visSectionScratch, iRowIndex, 4).Formula
- Row.D = shp.CellsSRC(visSectionScratch, iRowIndex, 5).Formula
- End Sub
-
- Sub GetStartPoint (shp As Object, iSection As Integer, Pnt As VisPoint)
- '-----------------------------------
- '--- GetStartPoint -----------------
- '--
- '-- Retrieves the start point row, AKA MoveTo row, from a shape sheet
- '-- geometry section.
- '--
- '-- Parameters : shp - Shape sheet to act on.
- '-- iSection - 1 based index of geometry section.
- '-- Pnt - VisPoint structure to receive point.
- '--
-
- If Not (iSection >= 1 And iSection <= GmtryCount(shp)) Then Exit Sub
-
- Pnt.X = shp.CellsSRC(visSectionFirstComponent + (iSection - 1), 1, 0).Formula
- Pnt.Y = shp.CellsSRC(visSectionFirstComponent + (iSection - 1), 1, 1).Formula
- End Sub
-
- Function GmtryCount (shp As Object) As Integer
- '-----------------------------------
- '--- GmtryCount --------------------
- '--
- '-- Returns the number of geometry sections in a shape sheet.
- '--
- '-- Parameters : shp - Shape to get geometry count from.
- '--
-
- If IsShape(shp) Then GmtryCount = shp.GeometryCount
- End Function
-
- Function HandleCount (shp As Object) As Integer
- '-----------------------------------
- '--- HandleCount -------------------
- '--
- '-- Returns the total number of control handles in a shape sheet. Zero is
- '-- returned even if shape is invalid.
- '--
-
- If IsShape(shp) Then
- HandleCount = shp.RowCount(visSectionControls)
- End If
- End Function
-
- Function IsShape (shp As Object) As Integer
- '-----------------------------------
- '--- IsShape -----------------------
- '--
- '-- Returns a boolean indicating if shp is a shape object
- '--
-
- IsShape = Not (shp Is Nothing) And Not (shp.Dump(0) <> visShape)
- End Function
-
- Sub SetClosedFlag (shp As Object, iSection As Integer, Flag As Variant)
- '-----------------------------------
- '--- SetClosedFlag -----------------
- '--
- '-- Changes the closed flag for a section. No changes are made if the
- '-- section doesn't exist.
- '--
- '-- Parameters : shp - Shape sheet on which to act.
- '-- iSection - 1 based index of geometry section to use. Do NOT
- '-- use section constats.
- '-- Flag - New formula for closed flag cell.
- '--
-
- 'IsShape is called indirectly by GmtryCount
- If Not (iSection >= 1 And iSection <= GmtryCount(shp)) Then Exit Sub
-
- shp.CellsSRC(visSectionFirstComponent + (iSection - 1), 0, 0).Formula = Flag
- End Sub
-
- Sub SetCnctPoint (shp As Object, iPos As Integer, NewPoint As CnctPoint)
- '-----------------------------------
- '--- SetCnctPoint ------------------
- '--
- '-- Sets a connection point using a CnctPoint structure. No changes are made
- '-- unless the point exists.
- '--
- '-- Parameters : shp - Shape sheet to get cell from.
- '-- iPos - 1 based index of connection point to replace.
- '-- Do NOT use row constants.
- '-- NewPoint - Contains new connection point contents.
- '--
-
- Dim iRowIndex As Integer
-
- 'If Not IsShape(shp) Then Exit Sub 'Called By TotalCnctPts
- If Not (iPos >= 1 And iPos <= TotalCnctPts(shp)) Then Exit Sub
-
- iRowIndex = visRowFirst + (iPos - 1)
-
- shp.CellsSRC(visSectionExport, iRowIndex, 0).Formula = NewPoint.X
- shp.CellsSRC(visSectionExport, iRowIndex, 1).Formula = NewPoint.Y
- End Sub
-
- Sub SetCtrlHandle (shp As Object, iPos As Integer, NewPoint As CtrlHandle)
- '-----------------------------------
- '--- SetCtrlHandle -----------------
- '--
- '-- Sets a control point using a CtrlHandle structure. No changes are made
- '-- unless the point exists.
- '--
- '-- Parameters : shp - Shape sheet to get cell from.
- '-- iPos - 1 based index of control point to replace. Do not
- '-- use row constants.
- '-- NewPoint - Contains new control handle contents.
- '--
-
- Dim iRowIndex As Integer
-
- 'If Not IsShape(shp) Then Exit Sub 'Called By TotalCtrlPts
- If Not (iPos >= 1 And iPos <= HandleCount(shp)) Then Exit Sub
-
- iRowIndex = visRowFirst + (iPos - 1)
-
- shp.CellsSRC(visSectionControls, iRowIndex, 0).Formula = NewPoint.X
- shp.CellsSRC(visSectionControls, iRowIndex, 1).Formula = NewPoint.Y
- shp.CellsSRC(visSectionControls, iRowIndex, 2).Formula = NewPoint.XDynamic
- shp.CellsSRC(visSectionControls, iRowIndex, 3).Formula = NewPoint.YDynamic
- shp.CellsSRC(visSectionControls, iRowIndex, 4).Formula = NewPoint.XBehavior
- shp.CellsSRC(visSectionControls, iRowIndex, 5).Formula = NewPoint.YBehavior
- shp.CellsSRC(visSectionControls, iRowIndex, 6).Formula = NewPoint.CanGlue
- End Sub
-
- Sub SetCtrlHandlePt (shp As Object, iPos As Integer, NewPoint As VisPoint)
- '-----------------------------------
- '--- SetCtrlHandlePt ---------------
- '--
- '-- Sets a control handles X,Y point only using a VisPoint structure. No
- '-- changes are made unless the point exists.
- '--
- '-- Parameters : shp - Shape sheet to get cell from.
- '-- iPos - 1 based index of control point to replace. Do not
- '-- use row constants.
- '-- NewPoint - Contains new control handle X,Y point.
- '--
-
- Dim iRowIndex As Integer
-
- 'If Not IsShape(shp) Then Exit Sub 'Called By TotalCtrlPts
- If Not (iPos >= 1 And iPos <= HandleCount(shp)) Then Exit Sub
-
- iRowIndex = visRowFirst + (iPos - 1)
-
- shp.CellsSRC(visSectionControls, iRowIndex, 0).Formula = NewPoint.X
- shp.CellsSRC(visSectionControls, iRowIndex, 1).Formula = NewPoint.Y
- End Sub
-
- Sub SetHiddenFlag (shp As Object, iSection As Integer, Flag As Variant)
- '-----------------------------------
- '--- SetHiddenFlag -----------------
- '--
- '-- Changes the hidden flag for a section. No changes are made if the
- '-- section doesn't exist.
- '--
- '-- Parameters : shp - Shape sheet on which to act.
- '-- iSection - 1 based index of geometry section to use. Do NOT
- '-- use section constats.
- '-- Flag - New formula for hidden flag cell.
- '--
-
- 'IsShape is called indirectly by GmtryCount
- If Not (iSection >= 1 And iSection <= GmtryCount(shp)) Then Exit Sub
-
- shp.CellsSRC(visSectionFirstComponent + (iSection - 1), 0, 2).Formula = Flag
- End Sub
-
- Sub SetScratchRow (shp As Object, iPos As Integer, NewRow As ScratchRow)
- '-----------------------------------
- '--- SetScratchRow -----------------
- '--
- '-- Set the contents of scratch rows using a ScratchRow structure. No changes
- '-- are made if the row doesn't exist.
- '--
- '-- Parameters : shp - Shape sheet to get cell from.
- '-- iPos - 1 based index of row to retrieve.
- '-- NewRow - Contains new contents for the row.
-
- Dim iRowIndex As Integer
-
- 'If Not IsShape(shp) Then Exit Sub 'Called By TotalScratchRows
- If Not (iPos >= 1 And iPos <= TotalScratchRows(shp)) Then Exit Sub
-
- iRowIndex = visRowFirst + (iPos - 1)
-
- shp.CellsSRC(visSectionScratch, iRowIndex, 0).Formula = NewRow.X
- shp.CellsSRC(visSectionScratch, iRowIndex, 1).Formula = NewRow.Y
- shp.CellsSRC(visSectionScratch, iRowIndex, 2).Formula = NewRow.A
- shp.CellsSRC(visSectionScratch, iRowIndex, 3).Formula = NewRow.B
- shp.CellsSRC(visSectionScratch, iRowIndex, 4).Formula = NewRow.C
- shp.CellsSRC(visSectionScratch, iRowIndex, 5).Formula = NewRow.D
- End Sub
-
- Sub SetStartPoint (shp As Object, iSection As Integer, Pnt As VisPoint)
- '-----------------------------------
- '--- SetStartPoint -----------------
- '--
- '-- Sets the start point row, AKA MoveTo row, in a shape sheet geometry
- '-- section.
- '--
- '-- Parameters : shp - Shape sheet to act on.
- '-- iSection - 1 based index of geometry section.
- '-- Pnt - VisPoint structure containing new point.
- '--
-
- If Not (iSection >= 1 And iSection <= GmtryCount(shp)) Then Exit Sub
-
- shp.CellsSRC(visSectionFirstComponent + (iSection - 1), 1, 0).Formula = Pnt.X
- shp.CellsSRC(visSectionFirstComponent + (iSection - 1), 1, 1).Formula = Pnt.Y
- End Sub
-
- Function TotalCnctPts (shp As Object) As Integer
- '-----------------------------------
- '--- TotalCnctPts ------------------
- '--
- '-- Returns the total number of connection points in a shape sheet. Zero is
- '-- returned even if the shape is invalid.
- '--
-
- If IsShape(shp) Then
- TotalCnctPts = shp.RowCount(visSectionExport)
- End If
- End Function
-
- Function TotalScratchRows (shp As Object) As Integer
- '-----------------------------------
- '--- TotalScratchRows --------------
- '--
- '-- Returns the total number of scratch rows in a shape sheet. Zero is
- '-- returned even if the shape is invalid.
- '--
-
- If IsShape(shp) Then
- TotalScratchRows = shp.RowCount(visSectionScratch)
- End If
- End Function
-
- Function VertexCount (shp As Object, iSection As Integer) As Integer
- '-----------------------------------
- '--- VertexCount -------------------
- '--
- '-- Returns the number of verticies in a shape sheet geometry section. This
- '-- count does not include the property row.
- '--
-
- If Not IsShape(shp) Then Exit Function
-
- VertexCount = shp.RowCount(visSectionFirstComponent + (iSection - 1)) - 1
- End Function
-
-